package com.zego.wawaji.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.zego.wawaji.base.module.ModuleMgr;
import com.zego.wawaji.ui.activity.MainActivity;
import com.zego.wawaji.ui.activity.web.WebActivity;
import com.zego.wawaji.ui.bean.wawa.WawaJi;
import com.zego.wawaji.ui.bean.wawa.WawaJiList;
import com.zego.wawaji.ui.center.about.AboutAct;
import com.zego.wawaji.ui.center.address.MyAddressAct;
import com.zego.wawaji.ui.center.address.MyEditAddressAct;
import com.zego.wawaji.ui.center.address.bean.Address;
import com.zego.wawaji.ui.center.credit.MyCreditAct;
import com.zego.wawaji.ui.center.invite.InviteAct;
import com.zego.wawaji.ui.center.pay.MyPropertyAct;
import com.zego.wawaji.ui.center.pay.bill.MyBillAct;
import com.zego.wawaji.ui.center.set.SettingAct;
import com.zego.wawaji.ui.center.transport.WawaLogisticsAct;
import com.zego.wawaji.ui.center.transport.bean.StepList;
import com.zego.wawaji.ui.play.PlayActivity;
import com.zego.wawaji.ui.rank.bean.Award;
import com.zego.wawaji.ui.rank.order.PrizeOrderActivity;
import com.zego.wawaji.ui.rank.prize.MyPrizeActivity;
import com.zego.wawaji.ui.rank.virtual.VirtualPrizeActivity;
import com.zego.wawaji.ui.start.NavUserAct;
import com.zego.wawaji.ui.start.RegMobileAct;
import com.zego.wawaji.ui.store.bean.Store;
import com.zego.wawaji.ui.store.car.StoreCarActivity;
import com.zego.wawaji.ui.store.convert.StoreConvertActivity;
import com.zego.wawaji.ui.store.declare.StoreDeclareActivity;
import com.zego.wawaji.ui.store.order.StoreOrderActivity;

/**
 * Created by Su on 2017/11/24.
 */
public class UIShow {

    public static void show(Context context, Intent intent) {
        context.startActivity(intent);
    }

    public static void show(Context context, Class clz, int flag) {
        Intent intent = new Intent(context, clz);
        if (flag != -1) intent.addFlags(flag);
        show(context, intent);
    }

    public static void show(Context context, Class clz) {
        show(context, clz, -1);
    }

    /**
     * 显示activity并清空栈里其他activity
     *
     * @param activity 要启动的activity
     */
    public static void showActivityClearTask(Context context, Class activity) {
        show(context, activity, Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    }

    /**
     * 跳转到主页并清除栈里的其他页面
     */
    public static void showMainClearTask(Context context) {
        showActivityClearTask(context, MainActivity.class);
    }

    /**
     * 跳转到网页
     *
     * @param type 1-侧滑页面，2-全屏页面，全屏时显示loading条  3-京东商品详情页  4-充值排行榜
     * @param url  网页地址
     */
    public static void showWebActivity(Context context, int type, String url) {
        Intent intent = new Intent(context, WebActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("url", url);
        intent.putExtra("type", type);
        show(context, intent);
    }

    /**
     * 打开导航页
     */
    public static void showNavUserAct(Context context) {
//        Intent intent = new Intent(context, NavUserAct.class);
//        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//        context.startActivity(intent);
        showActivityClearTask(context, NavUserAct.class);
    }

    /**
     * 打开设置页
     */
    public static void showSettingAct(Activity activity) {
        activity.startActivity(new Intent(activity, SettingAct.class));
    }

    /**
     * 打开手机登录页
     */
    public static void showRegMobileAct(Activity activity) {
        activity.startActivity(new Intent(activity, RegMobileAct.class));
    }

    /**
     * 打开游戏页
     *
     * @param room 房间信息
     */
    public static void showPlayActivity(Activity activity, WawaJi room) {
        Intent intent = new Intent(activity, PlayActivity.class);
        intent.putExtra("room", room);
        ModuleMgr.getWawaMgr().setLastWawaJi(room);
        activity.startActivity(intent);
    }

    /**
     * 打开我的娃娃: 物流信息
     */
    public static void showWaWaLogisticsAct(Activity activity, StepList stepList) {
        Intent intent = new Intent(activity, WawaLogisticsAct.class);
        intent.putExtra("stepList", stepList);
        activity.startActivity(intent);
    }

    /**
     * 我的娃娃币， 充值页面
     */
    public static void showMyPropertyAct(Activity activity) {
        activity.startActivity(new Intent(activity, MyPropertyAct.class));
    }

    /**
     * 我的娃娃币账单
     */
    public static void showMyBillAct(Activity activity) {
        activity.startActivity(new Intent(activity, MyBillAct.class));
    }

    /**
     * 我的积分
     */
    public static void showMyCreditAct(Activity activity) {
        activity.startActivity(new Intent(activity, MyCreditAct.class));
    }

    /**
     * 邀请他人
     */
    public static void showInviteAct(Activity activity) {
        activity.startActivity(new Intent(activity, InviteAct.class));
    }

    /**
     * 关于我们
     */
    public static void showAboutAct(Activity activity) {
        activity.startActivity(new Intent(activity, AboutAct.class));
    }

    /**
     * 收获地址
     *
     * @param channel 来源： 0： 添加收获地址  1： 确认发货  2: 充值排行榜发货
     * @param wawaNum 娃娃数量，供服务端做包邮判断使用
     */
    public static void showMyAddressAct(Activity activity, int channel, int wawaNum) {
        Intent intent = new Intent(activity, MyAddressAct.class);
        intent.putExtra("channel", channel);
        intent.putExtra("wawaNum", wawaNum);
        activity.startActivity(intent);
    }

    public static void showMyAddressAct(Activity activity) {
        showMyAddressAct(activity, 0, 0);
    }

    public static void showMyAddressPrizeAct(Activity activity, String ids) {
        Intent intent = new Intent(activity, MyAddressAct.class);
        intent.putExtra("channel", 2);
        intent.putExtra("ids", ids);
        activity.startActivity(intent);
    }


    /**
     * 收获地址: 编辑
     */
    public static void showMyEditAddressAct(Activity activity, Address address) {
        Intent intent = new Intent(activity, MyEditAddressAct.class);
        intent.putExtra("Address", address);
        activity.startActivity(intent);
    }

    /**
     * 商城购物车
     */
    public static void showStoreCarActivity(Activity activity, WawaJiList data) {
        Intent intent = new Intent(activity, StoreCarActivity.class);
        intent.putExtra("data", data);
        activity.startActivity(intent);
    }

    /**
     * 我的订单
     */
    public static void showStoreOrderActivity(Activity activity) {
        Intent intent = new Intent(activity, StoreOrderActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 商品：立即兑换
     */
    public static void showStoreConvertActivity(Activity activity, Store store) {
        Intent intent = new Intent(activity, StoreConvertActivity.class);
        intent.putExtra("store", store);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：虚拟奖品
     */
    public static void showStoreDeclareActivity(Activity activity) {
        Intent intent = new Intent(activity, StoreDeclareActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：我的奖品
     */
    public static void showMyPrizeActivity(Activity activity) {
        Intent intent = new Intent(activity, MyPrizeActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：虚拟奖品
     */
    public static void showVirtualPrizeActivity(Activity activity, Award award) {
        Intent intent = new Intent(activity, VirtualPrizeActivity.class);
        intent.putExtra("award", award);
        activity.startActivity(intent);
    }

    /**
     * 排行榜：发货订单
     */
    public static void showPrizeOrderActivity(Activity activity) {
        Intent intent = new Intent(activity, PrizeOrderActivity.class);
        activity.startActivity(intent);
    }
}
